package com.easyadmin.modules.stock.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.easyadmin.common.constant.SystemConstant;
import com.easyadmin.common.context.UserContext;
import com.easyadmin.common.web.domain.request.PageDomain;
import com.easyadmin.modules.stock.mapper.SysFuturesDao;
import com.easyadmin.modules.stock.service.SysFuturesService;
import com.easyadmin.modules.sys.domain.BOrderDispatch;
import com.easyadmin.modules.sys.domain.SysRole;
import com.easyadmin.modules.sys.mapper.SysRoleMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Authorization;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.easyadmin.modules.stock.domain.SysFuturesEntity;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;


@Service("sysFuturesService")
public class SysFuturesServiceImpl extends ServiceImpl<SysFuturesDao, SysFuturesEntity>
        implements SysFuturesService {

    @Resource
    SysFuturesDao sysFuturesDao;


    @Override
    public PageInfo<SysFuturesEntity> queryPage(SysFuturesEntity sysFuturesEntity, PageDomain pageDomain) {
        PageHelper.startPage(pageDomain.getPage(), pageDomain.getLimit());
        List<SysFuturesEntity> data =sysFuturesDao.selectList(new QueryWrapper<SysFuturesEntity>().lambda()
                .like(StringUtils.isNotBlank(sysFuturesEntity.getChinProd()),
                        SysFuturesEntity::getChinProd,sysFuturesEntity.getChinProd())
                .like(StringUtils.isNotBlank(sysFuturesEntity.getChinExchange()),
                        SysFuturesEntity::getChinExchange,sysFuturesEntity.getChinExchange()));
        return new PageInfo<>(data);
    }




    /**
     * Describe: 根据 id 删除某条数据
     * Param: id
     * Return: Boolean
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean remove(String id) {
        sysFuturesDao.deleteById(Integer.valueOf(id));
        return true;
    }



    /**
     * Describe: 修改用户数据
     * Param: SysUser
     * Return: 操作结果
     */
    @Override
    public boolean update(SysFuturesEntity sysFuturesEntity) {
        Integer result = sysFuturesDao.updateById(sysFuturesEntity);
        return result > 0;
    }


    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchRemove(String[] ids) {
        for(String  id:ids){
            sysFuturesDao.deleteById(id);
        }
        return true;
    }
}